﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi.PubDS
{
    [CPPEI.WebApi.AuthPostAction("PubDS", "DeleteDataSource", "1.0")]
    public class DeleteDataSourceAction : BaseAction<DeleteDataSourceParams, DeleteDataSourceResult>
    {
        protected override ActionResult<DeleteDataSourceResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            DeleteDataSourceParams opParams)
        {
            SER.PubSourceService service = new SER.PubSourceService();
            ServiceResult serResult = service.DeleteSource(opParams.Id);
            if(serResult.IsSuccess)
            {
                DeleteDataSourceResult result = new DeleteDataSourceResult();
                return new ActionResult<DeleteDataSourceResult>(result);
            }
            else
            {
                return new ActionResult<DeleteDataSourceResult>(serResult.IsSuccess, serResult.ErrorCode, serResult.Message, null);
            }
        }
    }

    public class DeleteDataSourceParams
    {
        public Guid Id { get; set; }
    }

    public class DeleteDataSourceResult
    {
    }
}
